Port the PaddlePaddle deltas from paddle/v1.27.0 onto 1.28.0 - #12
Merged
Conversation
Co-authored-by: root <root@tjdm-9d8tvhbv.bcc-tjdm.baidu.com>
Not a port: dsa_bwd_sm100_h16.py is new in upstream 1.28.0 (NVIDIA#664, added after v1.27.0 was cut). It is a copy of the dsa_bwd_sm100.py epilogue and carries the identical unclamped exp2 that PFCCLab#4 fixes in the main kernel, so the same NaN is reachable there. Drop this commit if you would rather keep the branch a strict port of paddle/v1.27.0.
The ported PaddlePaddle code predates the current .pre-commit-config.yaml (black, --line-length 160), so six files were not format-clean. The 1.28.0 base already was, and the pre-commit workflow runs `pre-commit run --all-files` on the PR head.
ForFishes
force-pushed
the
paddle/v1.28.0-port
branch
from
September 3, 2026 13:58
6736e52 to
ab75471
Compare
sneaxiy
approved these changes
Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Carry the PaddlePaddle deltas from
paddle/v1.27.0over to the newpaddle/v1.28.0branch. Without them Paddle cannot drive these kernels at all(the dtype tables resolve against PyTorch,
TensorDescrejects a Paddle place,torch.memory_formatdoes not exist,numel()becomes a blocking D2H, ...).Base is
paddle/v1.28.0= upstream1.28.0-rc@601b3f35f, which has the sametree (
b4b9b06cc) as thev1.28.0release tag, so the branch is pristineupstream 1.28.0 and this PR is exactly the Paddle delta on top of it.
Produced with
git rebase --onto <1.28.0 base> 0018f8dff paddle/v1.27.0, so everyoriginal commit keeps its author, message and granularity.
Commits
7f42e084ab717cb238ede4496ed7850f2aef928bb4389638dk_reduce_barrier, bothdenom_outbuffers still uninitialised1afa2ff3numel()Two of the nine
paddle/v1.27.0commits are not here, because on this basethey carry no content:
9d82b45b(Compat with PaddlePaddle) only added a Paddle-localnvtx_rangecontext manager to
_interface_sm100.pyandindexer_backward_sm100.py, whichadd compat for nvtx.range and ExternalStream #2 then replaced with the generic
torch.cuda.nvtx.rangeshim inutils/runtime.py. 1.28.0 already callstorch.cuda.nvtx.range, so the commitrebases to empty and git dropped it. The fork's net change to
_interface_sm100.pyis likewise zero.eb129d41(DSA backwardtopk_lengthloop + TMA fast path) was reverted byFix v1.27.0 error #8
2aef928b, so it has no net effect either. Replaying it would have meanthand-porting 315 lines onto the kernel upstream rewrote in Improve performance of SM100 DSA backward kernel NVIDIA/cudnn-frontend#684 only to revert
them again — and Fix v1.27.0 error #8's revert restores the 1.27.0 file, which would clobber
that rewrite. Skipped, which leaves Fix v1.27.0 error #8 as just its
indexer_backward/api.pyline (view(1)→reshape([1])).The v1.27.0
indexer_backward_sm100.pyperformance regression (range_constexpr→
range(unroll_full=True), upstream NVIDIA#376) is already fixed in 1.28.0 byupstream NVIDIA#549, so nothing is carried for it.
Conflict resolutions worth reviewing
Upstream reworked the code four of the fork hunks sat on:
datatypes.py_torch_to_cutlass_data_type— 1.28.0 resolves theframework via
sys.modules.get("torch")instead of importing it. A realPyTorch is commonly installed alongside Paddle, so that probe hands back
PyTorch and every Paddle dtype misses the mapping. Changed to probe
"paddle", which keeps upstream's "do not import on behalf of anotherframework" property. This one is load-bearing: without it
_torch_to_cutlass_data_type(paddle.bfloat16)returnsNoneand everydownstream dtype check silently degrades.
api_base.pyTensorDesc.__post_init__— gained the same_torch()probe plus a framework-neutral
Device. Probes Paddle directly and keepsDevicein the accepted set.api_base.pyis_contiguous— the v1.27.0 workaround is resolvedin favour of upstream. The old signature was
memory_format: torch.memory_format = torch.contiguous_format, which fails at def timebecause Paddle has no
memory_format; upstream changed it toAny = Noneand guards every torch reference, so the
raise NotImplementedErrorstopgapis no longer needed and the contiguity check works again under Paddle.
dsa_bwd_sm100.py— rewritten upstream by Improve performance of SM100 DSA backward kernel NVIDIA/cudnn-frontend#684, so [Fix] Protect prob <=1 when cudnn backward #4's clamp landed atthe new exp2 site by hand rather than as a context-matched patch.
Commit 8 is the one change that is not a port:
dsa_bwd_sm100_h16.pyis newin 1.28.0 (NVIDIA#664, added after v1.27.0 was cut), is a copy of the same epilogue and
carries the identical unclamped exp2. Drop that commit if you would rather keep
the branch a strict port.
Commit 9 exists because the ported Paddle code predates the current
.pre-commit-config.yaml(black,--line-length 160) and six files were notformat-clean; the 1.28.0 base already was.
Verification
black --line-length 160 --fastclean over all 18 touched files. No C/C++/CUDAfiles touched, so clang-format is a no-op. All 18 files byte-compile.
Smoke-tested on B30Z (sm_103) with Paddle 3.4.0 under
paddle.enable_compat(scope={"cudnn"}), which is howpaddlefleet_opsdrivesthis package:
import cudnnsucceeds and the eagerapi_base/DSAimports resolve (23 DSA symbols)_torch_to_cutlass_data_type:paddle.bfloat16→BFloat16,paddle.float32→Float32_is_torch_tensor(paddle_tensor)→ True;to_cute_tensorbuilds a cute tensor_validate_grad_loss_tensoraccepts(),(1,),(1,1)→ shape(1,); rejects numel 2 and fp16; and withTensor.numelmonkeypatched to raise, still passes — i.e. the guard is provably host-sideTensorDescaccepts a Paddle place andis_contiguous()returns Trueresolve_stream/torch_stream_contextround-tripNot verified: no kernel was actually launched, so the #9 dK barrier and the #4
clamp are carried on code review plus their original v1.27.0 validation, not on a
fresh numerical run.
Merge requirements
merge-requirementscurrently fails for two reasons, and only one of them ismine to fix:
PROJECT_READ_TOKENis not configured, so the workflowcannot read the Projects field and fails closed. That affects every PR on this
repo, not just this one, and needs a repo admin (or the
cat-routine-updatelabel as an exemption).